package org.rcloud.io.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.model.Activity;
import org.rcloud.io.model.Activity_copy;
import org.rcloud.io.service.ActivityService;
import org.rcloud.io.service.Activity_copyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.UUID;

/**
 * Created by Administrator on 2019/3/3.
 */
@RestController
@RequestMapping(value = "/Activity_copy")
public class Activity_copyController {
    @Autowired
    private Activity_copyService activity_copyService;

    @RequestMapping(value = "/add",produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    @CrossOrigin
    public ResultVo add(@RequestBody String params){
        JSONObject object = JSONObject.parseObject(params);
        object.put("id", UUID.randomUUID());
        object.put("createtime",new Date());
        object.put("flag",1);
        Activity_copy activity_copy = JSONObject.parseObject(object.toString(),Activity_copy.class);
        return activity_copyService.insertSelective(activity_copy);

    }

     /*
    * 修改
    *
    * */

    @RequestMapping(value = "/update", produces = {"application/json;charset=UTF-8"})
    public ResultVo update(@RequestBody String params) {
        Activity_copy activity_copy = JSONObject.parseObject(params, Activity_copy.class);
        return activity_copyService.updateByPrimaryKey(activity_copy);
    }

    /*
   * 查询
   *
   * */
    @RequestMapping(value = "/select", produces = {"application/json;charset=UTF-8"})
    public ResultVo select(@RequestBody String params) {
        Activity_copy activity_copy = JSONObject.parseObject(params, Activity_copy.class);
        return activity_copyService.selectByPrimaryKey(activity_copy);
    }

    /*
   * 分页查询
   *
   * */
    @RequestMapping(value = "/selectByOther", produces = {"application/json;charset=UTF-8"})
    public PageInfo<Activity_copy> selectByOther(@RequestBody JSONObject params) {
        PageInfo<Activity_copy> pageInfo = activity_copyService.selectByOther(params);
        return pageInfo;

    }



}
